package com.guyaning.deyson_core.core.delegates.web.event;

import android.annotation.SuppressLint;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.webkit.WebView;
import android.widget.Toast;

/**
 * Created by Administrator on 2018/7/12.
 */

public class TestEvent extends Event {

    @Override
    public String execute(String params) {

        Toast.makeText(getContext(),getAction(),Toast.LENGTH_LONG).show();

        final WebView webView = getmWebView();

        if(getAction().equals("test")){

            getmWebView().post(new Runnable() {
                @RequiresApi(api = Build.VERSION_CODES.KITKAT)
                @SuppressLint("JavascriptInterface")
                @Override
                public void run() {
                    webView.evaluateJavascript("nativeCall()",null);
                }
            });
        }
//        ToastUtils.showLong("exceute is"+params);
        return null;
    }
}
